#include "cpu/exec/helper.h"

make_helper(lods_b) {
    uint8_t value = swaddr_read(cpu.esi, 1);
    reg_b(R_AL) = value;
    cpu.esi += cpu.eflags.DF ? -1 : 1;

    print_asm("lodsb");
    return 1;
}

make_helper(lods_v) {
    if (ops_decoded.is_operand_size_16) {
        uint16_t value = swaddr_read(cpu.esi, 2);
        reg_w(R_AX) = value;
        cpu.esi += cpu.eflags.DF ? -2 : 2;
        print_asm("lodsw");
    }
    else {
        uint32_t value = swaddr_read(cpu.esi, 4);
        cpu.eax = value;
        cpu.esi += cpu.eflags.DF ? -4 : 4;
        print_asm("lodsd");
    }
    return 1;
}